const fs = require('fs');
const sass = require('node-sass')

const root = 'src/assets/template'

const files = fs.readdirSync(root)
const cssArr = []
for (let i = 0; i < files.length; i++) {
    const filePath = files[i]
    const data = fs.readFileSync(root + '/' + filePath, {encoding: 'utf-8'})
    console.log(data)
    const styleRes = sass.renderSync({
        file: root + '/' + filePath,
        outputStyle: 'compressed'

    })
    cssArr.push(styleRes.css.toString())
}


const cssString = cssArr.reduce((prev, current) => {
    return prev + `<style>${current}</style>\n`
}, '')

const cssInJsTemplate = "export default" + "`" + cssString + "`"
fs.writeFileSync('src/util/templateStyle.js', cssInJsTemplate, 'utf-8')

